package com.ruoyi.web.controller;

import com.ruoyi.business.Category;
import com.ruoyi.business.service.CategoryService;
import com.ruoyi.common.common.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @title: CategoryController
 * @copyright: copyright (c) 2021
 * @author: jiangguanjun
 * @date: 2023/2/2 16:55
 * @firstReview:
 * @lastReview:
 * @desc:品类相关
 */
@Api(value = "CustomerController", tags = "品类相关")
@RestController
@Slf4j
@RequestMapping("/category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService ;

    @CrossOrigin
    @GetMapping("/list")
    @ApiOperation(value = "类目列表，各个通过需要筛选类目的地方都可以用到")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cId", value = "类目id", required = false,dataType = "Integer"),
            @ApiImplicitParam(name = "type", value = "类型，0：父类类目，1：子类类目" ,required = false, dataType = "Integer")
    })
    public ResultBody<Category> list(@RequestParam(value = "cId",required = false) Integer cId, @RequestParam(value="type" ,required = false) Integer type){
        log.info("传入参数cId：{},type:{}",cId,type);
        return categoryService.list(cId,type);
    }



}
